home *** CD-ROM | disk | FTP | other *** search
/ Almathera Ten Pack 2: CDPD 1 / Almathera Ten on Ten - Disc 2: CDPD 1.iso / pd / 351-375 / 351 / pdc / pdcsrc.lzh / PDC / memset.c < prev    next >
C/C++ Source or Header  |  1990-04-06  |  548b  |  34 lines

  1.  
  2. /*
  3.  * memset - set bytes
  4.  *
  5.  * CHARBITS should be defined only if the compiler lacks "unsigned char".
  6.  * It should be a mask, e.g. 0377 for an 8-bit machine.
  7.  */
  8.  
  9. #include "config.h"
  10.  
  11. #ifndef CHARBITS
  12. #    define    UNSCHAR(c)    ((unsigned char)(c))
  13. #else
  14. #    define    UNSCHAR(c)    ((c)&CHARBITS)
  15. #endif
  16.  
  17. VOIDSTAR
  18. memset(s, ucharfill, size)
  19. CONST VOIDSTAR s;
  20. register char ucharfill;
  21. SIZET size;
  22. {
  23.     register CONST char *scan;
  24.     register SIZET n;
  25.     register char uc;
  26.  
  27.     scan = s;
  28.     uc = UNSCHAR(ucharfill);
  29.     for (n = size; n > 0; n--)
  30.         *scan++ = uc;
  31.  
  32.     return(s);
  33. }
  34.